//
// Created by liang on 2025/4/5.
//

#ifndef QT6_TEST_MAINWINDOW_H
#define QT6_TEST_MAINWINDOW_H
#include <QPushButton>

#include "ExecuteThread.h" // 添加头文件包含

#include "WindowControl.h"
using namespace SS;
class ExecuteThread;
namespace SS {
    class MainWindow : public QWidget{
        Q_OBJECT
    public:

        explicit MainWindow(QWidget *parent = nullptr): startUpBtn(new QPushButton()),
                                                        QWidget(parent) {
        }

        QPushButton *startUpBtn;
        void setupUi()
        {
            auto windows = windowControl.getAllWindows();
            for (auto& item : windows) {
                auto threadItem = std::make_unique<ExecuteThread>(item.second);
                threadItem->start();
                this->threads.push_back(std::move(threadItem));
            }
            this->setWindowTitle("Qt6 Button Event Example");
            this->resize(600, 500);
            startUpBtn->setParent(this);
            startUpBtn->setText("启动");
            startUpBtn->setGeometry(100, 80, 100, 30);
            QObject::connect(startUpBtn, &QPushButton::clicked, this, &MainWindow::startUpEvent);
            this->show();
        }
    public slots:
        void startUpEvent();
    protected:
        void keyPressEvent(QKeyEvent *event) override;
    private:
        std::vector<std::unique_ptr<ExecuteThread>> threads;
        WindowControl windowControl;
    };
}






#endif //QT6_TEST_MAINWINDOW_H
